Skip to content

[codex] refactor server cloud Effect services#3183

Merged
juliusmarminge merged 1 commit into
mainfrom
codex/effect-service-server-cloud
Jun 20, 2026
Merged

[codex] refactor server cloud Effect services#3183
juliusmarminge merged 1 commit into
mainfrom
codex/effect-service-server-cloud

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • inline the cloud CLI token manager and managed endpoint runtime contracts on their Context.Service tags
  • export each concrete service's canonical make and layer values and reference contracts through Service["Service"]
  • replace the CLI token manager's operation-switched error with five concrete Schema.TaggedErrorClass failures and an exported Schema.Union
  • namespace-import service-bearing modules while retaining named imports for contracts and pure helper/config APIs
  • preserve the current server/config migrations; the diff remains limited to five cloud files with no orchestration, MCP, or harness changes

Design notes

Credential removal, credential refresh, credential read, authorization, and authorization timeout are materially different failures, so each now has its own tag and required structured cause. The HTTP boundary handles all concrete tags through the shared inferred error union.

Both service constructors are effectful and dependency-backed, and the managed endpoint runtime owns lifecycle finalization. Their layers therefore use Layer.effect. Existing managed-endpoint tests construct the service through its production layer so startup and finalization remain covered; no refactor-only test cases were added.

Validation

  • vp test run apps/server/src/cloud/ManagedEndpointRuntime.test.ts apps/server/src/cloud/http.test.ts apps/server/src/server.test.ts (3 files, 110 tests)
  • vp check (zero errors; 20 pre-existing warnings)
  • vp run typecheck
  • git diff --check origin/main...HEAD
  • audit: two inline service contracts, two exported canonical make/layer pairs, zero standalone target service-shape references, exact parity across 13 changed-file test declarations, comments preserved, and no excluded paths

Note

Low Risk
Structural refactor in non-orchestration cloud paths; CLI errors gain distinct _tag values but HTTP still maps them to the same internal error messages.

Overview
This PR restructures the server cloud module’s Effect services without changing OAuth, tunnel, or HTTP behavior.

CLI token manager replaces one Data.TaggedError with operation-specific Schema.TaggedErrorClass types (read, refresh, authorize, timeout, removal) united as CloudCliTokenManagerError, and maps failures through typed constructors instead of generic message strings. The service contract moves inline on Context.Service, and make is exported as the canonical factory.

Managed endpoint runtime drops standalone *Shape interfaces, renames makeCloudManagedEndpointRuntime to make (startup config + teardown finalizer live in that effect), and exposes layer as Layer.effect(Service, make). Process/HTTP imports use explicit submodule paths.

Cloud HTTP and tests switch to namespace imports and Service["Service"] for dependency typing; reconcileDesiredCloudLink catches each CLI error tag separately while still surfacing the same user-facing messages via error.message.

Reviewed by Cursor Bugbot for commit 5b7c67c. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Refactor cloud Effect services to use specific error classes and namespace imports

  • Replaces the single generic CloudCliTokenManagerError with five specific error classes (CloudCliCredentialRemovalError, CloudCliCredentialRefreshError, CloudCliCredentialReadError, CloudCliAuthorizationError, CloudCliAuthorizationTimeoutError), each preserving the original cause.
  • Updates ManagedEndpointRuntime to consolidate the factory into export const make, inline the service shape, and simplify layer construction.
  • Updates http.ts to catch and map each specific token manager error variant via a new failCloudCliTokenManagerError helper, rather than a single generic catch.
  • Replaces direct named imports with namespace imports across all affected cloud modules and tests for consistency with Effect conventions.

Macroscope summarized 5b7c67c.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b47b88e1-4557-4d3d-ac2b-f5101b6b70ad

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/effect-service-server-cloud

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

🚀 Expo continuous deployment is ready!

  • Project → t3-code
  • Platforms → android, ios
  • Scheme → t3code-preview
  🤖 Android 🍎 iOS
Fingerprint fe5a51f2e189da69dfc4c2cd458e6cfb5fdff2ea ae3bd597809dfd7771d0898f735d172973d4c1c8
Build Details Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: fe5a51f2e189da69dfc4c2cd458e6cfb5fdff2ea
App version: 0.1.0
Git commit: 9686572d2811e7a21db1e2bd2bcbba8981c5f3e8
Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: ae3bd597809dfd7771d0898f735d172973d4c1c8
App version: 0.1.0
Git commit: b4706aa685da92ae179e34c97839c2a0e9840f09
Update Details Update Permalink
DetailsBranch: pr-3183
Runtime version: fe5a51f2e189da69dfc4c2cd458e6cfb5fdff2ea
Git commit: 9686572d2811e7a21db1e2bd2bcbba8981c5f3e8
Update Permalink
DetailsBranch: pr-3183
Runtime version: ae3bd597809dfd7771d0898f735d172973d4c1c8
Git commit: 9686572d2811e7a21db1e2bd2bcbba8981c5f3e8
Update QR

@juliusmarminge juliusmarminge marked this pull request as ready for review June 20, 2026 02:06
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Mechanical refactor restructuring Effect service error classes and import patterns. Error messages, handling logic, and runtime behavior remain unchanged.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge juliusmarminge force-pushed the codex/effect-service-server-cloud branch from f13cb39 to fa1e928 Compare June 20, 2026 02:35
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 02:35

Dismissing prior approval to re-evaluate fa1e928

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@juliusmarminge juliusmarminge force-pushed the codex/effect-service-server-cloud branch from fa1e928 to 7e190c0 Compare June 20, 2026 03:20
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 03:20

Dismissing prior approval to re-evaluate 7e190c0

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@juliusmarminge juliusmarminge force-pushed the codex/effect-service-server-cloud branch from 7e190c0 to 9b12996 Compare June 20, 2026 03:25
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 03:26

Dismissing prior approval to re-evaluate 9b12996

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the codex/effect-service-server-cloud branch from 9b12996 to 5b7c67c Compare June 20, 2026 03:45
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 03:45

Dismissing prior approval to re-evaluate 5b7c67c

@juliusmarminge juliusmarminge merged commit 4ee719a into main Jun 20, 2026
15 checks passed
@juliusmarminge juliusmarminge deleted the codex/effect-service-server-cloud branch June 20, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant